Carbon


ThreadID

Header: Threads.h

The ThreadID data type defines the thread ID.

enum ThreadID {
    kNoThreadID = ,
    kCurrentThreadID = 1,
    kApplicationThreadID = 2
};

Constant descriptions

kNoThreadID

Indicates no thread; for example, you can use a function such as SetThreadState (page 2) to put the current thread in the stopped state and pass kNoThreadID to indicate that you donít care which thread runs next.

kCurrentThreadID

Identifies the currently executing thread.

kApplicationThreadID

Identifies the main application thread; this is the cooperative thread that the Thread Manager creates at launch time. You cannot dispose of this thread. All applicationsóeven those that are not aware of the Thread Manageróhave one main application thread. The Thread Manager assumes that the main application thread is responsible for event gathering; when an operating-system event occurs, the Thread Manager schedules the main application thread as the next thread to execute.

The Thread Manager assigns a thread ID to each thread that you create or allocate with the NewThread function. The thread ID uniquely identifies a thread within an application context. You can use the thread ID in functions that schedule execution of a particular thread, dispose of a thread, and get and set information about a thread; for example, you pass the thread ID to functions such as YieldToThread, DisposeThread, and GetThreadState.

In addition to the specific thread IDs that the NewThread function returns, you can use the three Thread Manager constants described here.


© 2000 Apple Computer, Inc. — (Last Updated 3/8/2000)